// -------------------账户管理-------------------
import fetch from '../config/fetch'

/**
 * 创建课程
 * params: {
  "brief": "string",
  "cover": "string",
  "name": "string"
}
 */
export const createCourse = (data) => fetch({
  url: '/course/v1',
  method: "post",
  data: data
});

/**
 * 删除某一个课程
 */
export const deleteCourse = (id) => fetch({
  url: '/course/v1/' + id,
  method: "delete",
  data: {}
});

/**
 * 修改课程
 * parmas:{
  "brief": "string",
  "cover": "string",
  "name": "string"
}
 */
export const updateCourse = (id, data) => fetch({
  url: '/course/v1/' + id,
  method: "put",
  data: JSON.stringify(data)
});

/**
 * 获取企业的签约课程和未签约课程列表
 */
export const getCourse = () => fetch({
  url: '/course/v1/signOrNotSign',
  method: "get",
  data: {}
});

/**
 * 创建课程价格
 * params: {
  "amount": 0,
  "courseId": 0,
  "effectiveLength": 0,
  "effectiveLengthUnit": "FOREVER"
}
 */
export const creatPrice = (data) => fetch({
  url: '/price/v1',
  method: "post",
  data: data
});

/**
 * 获取所有课程价格
 */
export const getAllPrice = () => fetch({
  url: '/price/v1/all',
  method: "get",
  data: {}
});

/**
 * 获取所有课程价格
 */
export const getAllPriceByOrgId = (id) => fetch({
  url: '/price/v1/orgId',
  method: "get",
  data: {orgId: id}
});

/**
 * 获取某一个课程的价格
 */
export const getPrice = (id) => fetch({
  url: '/price/v1/' + id + '/all',
  method: "get",
  data: {}
});

/**
 * 删除课程价格
 */
export const deletePrice = (id) => fetch({
  url: '/price/v1/' + id,
  method: "delete",
  data: {}
});

/**
 * 编辑课程价格
 * params: {
  "amount": 0,
  "courseId": 0,
  "effectiveLength": 0,
  "effectiveLengthUnit": "FOREVER"
}
 */
export const updatePrice = (id, data) => fetch({
  url: '/price/v1/' + id,
  method: "put",
  data: data
});

/**
 * 添加课程试用时间
 */
export const addCourseTime = (endUserId, courseId, time) => fetch({
  url: '/user/v1/giveCourse',
  method: "post",
  data: {
    endUserAccountId: endUserId,
    courseId: courseId,
    time: time,
  }
});


// -----------------课程管理-------------------

/**
 * 获取所有课程
 */
export const getAllCourse = () => fetch({
  url: '/course/v1/all',
  method: "get",
  data: {},
});

/**
 * 查询自己签约的合同
 */
export const getOwnerCourse = () => fetch({
  url: '/contract/v1/owner',
  method: "get",
  data: {},
});

/**
 * 获取课程价格
 */
export const getCoursePrice = (courseId) => fetch({
  url: '/price/v1/' + courseId + '/all',
  method: "get",
  data: {},
});
// -----------------课程管理-------------------


